<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="vi" xml:lang="vi">
    <head>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
        <meta charset="<?php bloginfo('charset'); ?>" />
        <!-- add meta for page -->
        <meta name="robots" content="INDEX,FOLLOW" />
        <meta name="description" content="Sloggy"/>
        <meta name="keywords" content="Mini game" />	
        <meta property="fb:admins"               content="minhson226"/>
        <meta property="og:type"                 content="website"/>
        <meta property="og:url"                  content="https://www.facebook.com/sloggi.vn‎"/>
        <meta property="og:image"                content="http://vietbuzzad.net/sloggimanager/wp-content/themes/eb_sloggy/images/sloggy.png"/>            
        <meta property="og:title"                content="Mini Game"/>
        <meta property="og:description"          content="Nhập hội sloggi facebook - thế giới trang phục lót sloggi xinh tươi, ngộ nghĩnh đã và đang làm say mê biết bao bạn trẻ trên toàn thế giới."/>
        <!-- end meta for page -->

        <title> <?php wp_title('|', true, 'right'); ?></title>

        <link href="<?php echo bloginfo('template_url'); ?>/css/default.css?t=1" rel="stylesheet" type="text/css"/>
        <script src="<?php echo bloginfo('template_url'); ?>/js/jquery-1.6.1.min.js" type="text/javascript"></script>
        <?php wp_head(); ?>

        <style type="text/css">
            html {
                margin-top: 0px !important;
            }
			.gametop {
  height: 372px;
 
}
        </style>
        <script type="text/javascript" charset="utf-8">
            jQuery(document).ready(function() {
/*
                jQuery('.main').click(function() {
                    ele_id = jQuery(this).attr('eleid');
                    jQuery(this).fadeOut();
                    jQuery('#' + ele_id).fadeIn();
                });
*/
                //FB share
                jQuery('#fbshare').click(function() {
                    window.open("https://www.facebook.com/sharer/sharer.php?u=https://www.facebook.com/sloggi.vn/app_190322544333196", "FB share", "width=500,height=200,scrollbars=no");
                });
                //Filter 
                jQuery('#gameFilter').change(function() {
                    eleid = jQuery(this).val();
                    if (eleid) {
                        document.location.href = "<?php echo site_url() ?>/?g=" + eleid;
                    } else {
                        document.location.href = "<?php echo site_url() ?>";
                    }
                });
				
				jQuery('.thumbobj').click(function(){
						xid = jQuery(this).attr('rel');
						jQuery('.abc').fadeOut();
						jQuery('#' + xid).fadeIn();
				});
            });
        </script>
    </head>
    <?php
    global $wpdb;
    $tb = 'wp_game';
    $allgame = $wpdb->get_results("SELECT * FROM $tb");
    $option = get_option('eb_sloggy_1_settings');
    ?>
    <body style="width:780px; height: 100%;">
        <div id="container">
            <div class="header">

                <div class="logo">
					<a href="<?php echo $option['logolink'] ?>"> 
						<img src="<?php echo bloginfo('template_url'); ?>/images/sloggy2.png" />
					</a>
				</div> 
<!--
                <div class="gametop"><a href='<?php echo site_url() ?>'><img src="<?php echo bloginfo('template_url'); ?>/images/hotgirl.png" /></a></div>
-->
                <div class="droparea">
                    <a href='<?php echo site_url() ?>'>
                        <img src="<?php echo bloginfo('template_url'); ?>/images/minigame.png" /></a> <br />
                    <select id="gameFilter" onchange="">
                        <option selected  value="0">Hiển thị tất cả game</option>
                        <?php
                        foreach ($allgame as $row) {
									$row->title  = str_replace('\\"','"', $row->title);

                            $select = isset($_GET['g']) && $_GET['g'] == $row->id ? 'selected' : '';
                            echo "<option value='{$row->id}' $select >{$row->title}</option>";
                        }
                        ?>
                    </select>
                    <br />
                    <div class="fbshare" id="fbshare"><img src="<?php echo bloginfo('template_url'); ?>/images/fb.jpg" /></div>
                </div>
                <div style="clear:both;"></div>
            </div>
            <div class="content">

                <?php
                $passgame = $wpdb->get_results("SELECT * FROM $tb ORDER BY is_top DESC ");

                foreach ($passgame as $k => $row) {
                    if(isset($_GET['g']) && $_GET['g'] && $_GET['g'] != $row->id)
                        continue;
                    
                    $thele = $row->thele_type == 'external' ? $row->thele_external : get_page_link($row->thele_internal);
                    $ketqua = $row->ketqua_type == 'external' ? $row->ketqua_external : get_page_link($row->ketqua_internal);
                    ?>
                    <?php if ($row->is_top) { ?>
                        <div class="main" eleid="block_id_<?php echo $row->id ?>" > <img src="<?php echo $row->banner ?>" width="800" > </div>
                    <?php } ?>
                    <div id="block_id_<?php echo $row->id ?>" <?php echo $row->is_top ? "style='display:none;'" : ''; ?>>
                        <div class="block gallery">
                            <div class="name">
                                <label><img src="<?php echo bloginfo('template_url'); ?>/images/0.jpg" /><img src="<?php echo bloginfo('template_url'); ?>/images/<?php echo $k + 1 ?>.jpg" /></label>
                                <div class="title"><img src="<?php echo $row->name ?>" /></div>
                                <div style="clear:both;"></div>
                            </div>
                            <div class="thele thumbobj"  rel="thele_<?php echo $k ?>" >
                                    <img class="thumb" src ="<?php echo $row->thele_image ?>" />
                                    <p><img src="<?php echo bloginfo('template_url'); ?>/images/thele.jpg" /></p>
                            </div>
                            <div class="ketqua thumbobj" rel="ketqua_<?php echo $k ?>">

                                    <img class="thumb"  src="<?php echo $row->ketqua_image ?>" />
                                    <p><img src="<?php echo bloginfo('template_url'); ?>/images/ketqua.jpg" /></p>
                            </div>
                            <div style="clear:both;"></div>
                        </div>
						<div style='margin-left: 5px; <?php echo isset($_GET['g']) ? '' : 'display:none;' ; ?>' class="abc" id="thele_<?php echo $k ?>">
                                <iframe width="800" height="<?php echo isset($_GET['g']) ? 1400 : 400 ; ?>" frameborder="0"  src="<?php echo $thele ?>"></iframe> 
                            </div>
							<div style='margin-left: 5px; display:none;' class="abc" id="ketqua_<?php echo $k ?>">
                                <iframe width="800" height="<?php echo isset($_GET['g']) ? 1400 : 400 ; ?>" frameborder="0"  src="<?php echo $ketqua ?>"></iframe> 
                            </div>
                        <?php if ($row->is_top) { ?>
                            <div style='margin-left: 5px;' class="abc">
                                <iframe width="795" height="<?php echo $row->iframe_height ?>" frameborder="0" scrolling="no" src="<?php echo $row->app_url ?>"></iframe> 
                            </div>
                        <?php } ?>
                    </div>
                <?php } ?>

            </div>
        </div>
    </body>
</html>